package com.cjq.auth.controller;

import com.cjq.auth.service.AuthService;
import com.cjq.common.domain.User;
import com.cjq.common.domain.request.UserReq;
import com.cjq.common.domain.response.UserRes;
import com.cjq.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class AuthController {
    @Autowired
    private AuthService authService;

    /**
     * 手机号获取验证码
     * @param
     * @return
     */
    @PostMapping("/getCode/{phone}")
    public Result getCode(@PathVariable String phone){
        return authService.getCode(phone);
    }

    /**
     * 手机号验证码登录
     * @param userReq
     * @return
     */
    @PostMapping("/phoneLogin")
    public Result<UserRes> phoneLogin(@RequestBody UserReq userReq){
        return authService.phoneLogin(userReq);
    }

    /**
     * 获取用户信息
     * @return
     */
    @GetMapping("/userInfo")
    public Result<User> userInfo(){
    	return authService.userInfo();
    }

    /**
     * 退出登录
     * @return
     */
    @PostMapping("/logout")
    public Result logout(){
        return authService.logout();
    }
}
